<?php
namespace app\logic;

use app\common\corelib\CacheHelper;
use app\models\Address;
use app\models\Favorite;
use app\models\Goods;
use app\models\Tag;
use app\models\User;
use yii\base\Security;
use yii\db\Query;



class UserLogic
{

    public function addUser($mobile,$token,$password){
        $user = new User();
        $user->mobile = $mobile;
        $user->zj_token = $token;
        $user->save();
        return $user->toArray();
    }

    public function updateUser($mobile,$token){
        $user = User::findOne(['mobile'=>$mobile]);
        if($user){
            $user->access_token = $token;
            $user->save();
        }else{
            $user = new User();
            $user->mobile = $mobile;
            $user->access_token = $token;
            $user->save();
        }
        return $user->toArray();
    }

    public function getById($user_id){
        return User::findOne($user_id)->toArray();
    }

}